package com.uwo.house.service.serviceImpl;

import com.uwo.house.beans.request.DecorationScheduleReq;
import com.uwo.house.beans.request.MaterialStatusReq;
import com.uwo.house.beans.response.ConstructionScheduleResp;
import com.uwo.house.beans.response.DecorationPlanResp;
import com.uwo.house.beans.response.MaterialListResp;
import com.uwo.house.dao.DecorationSchemeDao;
import com.uwo.house.dao.DesignOrderStatusDao;
import com.uwo.house.dao.MaterialStatusDao;
import com.uwo.house.service.IDecorationSchemeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by YZYG on 2017/7/17.
 */
@Service
public class DecorationSchemeService implements IDecorationSchemeService {
    @Autowired
    public DecorationSchemeDao decorationSchemeDao;

    @Autowired
    public MaterialStatusDao materialStatusDao;

    @Autowired
    public DesignOrderStatusDao designOrderStatusDao;

    public List<DecorationPlanResp> getDecorationList(String loginUser,String planSts){
        return decorationSchemeDao.getDecorationList(loginUser,planSts);
    }

    public DecorationPlanResp getDecorationDetails(String id){
        return decorationSchemeDao.getDecorationDetails(id);
    }

    public int confirmPlan(int planId) {
        return decorationSchemeDao.confirmPlan(planId);
    }

    public void abandonPlan(String orderId, int planId) {
        decorationSchemeDao.abandonPlan(orderId, planId);
        decorationSchemeDao.deleteMaterialList(orderId,planId);
        designOrderStatusDao.updateAllOrderStatus(orderId);
    }

    public String getMaterialList(String orderId, int planId){
        return decorationSchemeDao.getMaterialList(orderId,planId);
    }

    public void addMaterialStatus(String orderId, int planId) {
        List<MaterialStatusReq> list = decorationSchemeDao.getMaterialStatusList(orderId, planId);
        for (MaterialStatusReq materialStatusReq : list) {
            this.materialStatusDao.addMaterialStatus(materialStatusReq);
        }
    }

    public List<ConstructionScheduleResp> geConstructionSchedule(String orderId){
        return decorationSchemeDao.geConstructionSchedule(orderId);
    }

    public int checkProject(String id){
        return decorationSchemeDao.checkProject(id);
    }

    public int addDecorationSchedule(DecorationScheduleReq decorationScheduleReq) {
        return decorationSchemeDao.addDecorationSchedule(decorationScheduleReq);
    }

    public List<MaterialListResp> getDecorationMaterialDetails(Integer id){
        return decorationSchemeDao.getDecorationMaterialDetails(id);
    }

}
